package com.yiji.fintech.musfinance.center.deposit.order.facade;

import com.acooly.core.common.exception.OrderCheckException;
import com.acooly.core.utils.Money;
import com.acooly.core.utils.Strings;
import com.acooly.core.utils.ToString;
import com.google.common.collect.Lists;
import com.yiji.fintech.musfinance.base.enums.TradeTypeEnum;
import com.yiji.fintech.musfinance.center.base.order.OrderFacade;
import lombok.Data;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.NotNull;

/**
 * 扫描支付 （所有扫码通用）
 * Created by ouwen@yiji.com} on 2017/5/2.
 */
@Data
public class ScanCodePayFacadeOrder extends OrderFacade {
    /**付款金额*/
    @NotNull
    private Money amount;
    /**商品描述*/
    @NotEmpty
    private String goodsMemo;
    /** 终端IP */
    @NotEmpty
    private String mchCreateIp;
    /** 微信、支付宝授权码-被扫必填*/
    private String authCode;
    @Override
    public void check() {
       //微信支付宝授权码
      if(Lists.newArrayList(TradeTypeEnum.ALI_SCAN_CODEED_PAY,
              TradeTypeEnum.WECHAT_SCAN_CODEED_PAY).contains(getTradeType())){
          if(Strings.isEmpty(authCode)){
              throw new OrderCheckException("微信、支付宝授权码被扫授权码不能为空", "请求参数不完整:");
          }
      }
    }
    @Override
    public String toString() {
        return ToString.toString(this);
    }
}
